﻿using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;

namespace YJKDataBase
{
	public class INIClass
	{
		[DllImport("kernel32")]
		private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);

		[DllImport("kernel32")]
		private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);

		public INIClass(string INIPath)
		{
			this.inipath = INIPath;
		}

		public void IniWriteValue(string Section, string Key, string Value)
		{
			INIClass.WritePrivateProfileString(Section, Key, Value, this.inipath);
		}

		public string IniReadValue(string Section, string Key)
		{
			StringBuilder stringBuilder = new StringBuilder(500);
			INIClass.GetPrivateProfileString(Section, Key, "", stringBuilder, 500, this.inipath);
			return stringBuilder.ToString();
		}

		public bool ExistINIFile()
		{
			return File.Exists(this.inipath);
		}

		public string inipath;
	}
}
